#!/usr/bin/env bash


function getConfig()
{
  local -r username="$(kubectl -n ${ns} get secret rabbitmq-default-user -o jsonpath='{.data.username}' | base64 --decode)"
  echo "username: $username"
  local -r password="$(kubectl -n ${ns} get secret rabbitmq-default-user -o jsonpath='{.data.password}' | base64 --decode)"
  echo "password: $password"
}

function addUser()
{
  local -r pod="rabbitmq-server-0"

  echo "run command:  kubectl -n ${ns} exec -it ${pod} -- bash"
  echo ""
  echo "rabbitmqctl add_user ${1} ${2}"
  echo "rabbitmqctl set_user_tags ${1} administrator"
  echo "rabbitmqctl set_permissions -p '/' ${1} '.*' '.*' '.*'"

  echo ""
}

declare -r ns="devops"

getConfig
echo ""

addUser "customer" "customer88."
addUser "onlyoffice" "customer88."
addUser "coremis" "customer88."
